package com.zr.dto;

import java.util.List;

/**
 * 分页查询结果模型
 * @author Administrator
 * @param <T>
 */
public class PaginationResult<T> extends QueryResult<T> {
	private static final long serialVersionUID = 139388877941624007L;
	private int totalPages=-1;
	private int pageSize;
	private int pageNo;
	
	public PaginationResult() {
		super();
	}
	public PaginationResult(int totalSize,List<T> data) {
		super(data);
		this.setTotalRecords(totalSize);
	}
	public PaginationResult(long totalSize,List<T> data) {
		super(data);
		this.setTotalRecords(totalSize);
	}
	public int getTotalPages() {
		if(this.getTotalRecords()<=0)return 0;
		int tp=this.totalPages;
		if(tp==-1){
			int tr=this.getTotalRecords();
			int ps=this.getPageSize();
			tp=tr/ps;
			if((tr%ps)!=0){
				tp++;
			}
		}
		return tp;
	}
	public int getPageSize() {
		return pageSize;
	}
	public int getPageNo() {
		return pageNo;
	}
	
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	@Override
	public String toString() {
		return "PaginationResult [totalPages=" + totalPages + ", pageSize="
				+ pageSize + ", pageNo=" + pageNo + ", getTotalPages()="
				+ getTotalPages() + ", getPageSize()=" + getPageSize()
				+ ", getPageNo()=" + getPageNo() + ", isNotFind()="
				+ isNotFind() + ", isFind()=" + isFind() + ", getMessage()="
				+ getMessage() + ", getTotalRecords()=" + getTotalRecords()
				+ ", getExt()=" + getExt() + ", getRows()=" + getRows()
				+ ", getClass()=" + getClass() + ", hashCode()=" + hashCode()
				+ ", toString()=" + super.toString() + "]";
	}
	
}
